home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / tex / xtexcad-.000 / xtexcad- / orig_src / io_trans.c < prev    next >
C/C++ Source or Header  |  1993-03-04  |  36KB  |  1,740 lines

  1. /* xtexcad  V1.2 - graphic editor for LaTeX */
  2. /* 1991 by K.Zitzmann */
  3. /* io_trans.c */
  4.  
  5.  
  6. #include "x_stuff.h"
  7. #include "oberfl.h"
  8. #include "graphics.h"/* xtexcad  V1.1 - graphic editor for LaTeX */
  9. /* 1991 by K.Zitzmann */
  10. /* io_trans.c */
  11.  
  12.  
  13. #include "x_stuff.h"
  14. #include "oberfl.h"
  15. #include "graphics.h"
  16. #include "io_trans.h"
  17. #include "yyscan.h"
  18.  
  19.  
  20. float    dim_x_max = -99999.0, dim_x_min = 99999.0, dim_y_max = -99999.0, dim_y_min = 99999.0;
  21.  
  22. static struct object_buffer
  23. {
  24.     float           xpos, ypos, hpos, vpos, dash_length;
  25.     float        sxpos,sypos; /* for curves only ! */
  26.     char            text[256];    /* that should be enough !!! */
  27.     char            textpos[2];
  28.     int             radius;
  29. }               buffer;    /* the buffer struct - used while scanning
  30.              * LaTeX-sources */
  31.  
  32.  
  33. int      unit = 1;    /* 1=pt 2=cm 3=mm 4=pc 5=in */
  34. float    ulen = 1.0;    /* unitlength */
  35.  
  36.  
  37.  
  38.  
  39. Boolean
  40. file_exists(char *fn)
  41. {
  42.     FILE           *fd;
  43.     Boolean         res;
  44.     if ((fd = fopen(fn, "r")) == NULL)
  45.         res = False;
  46.     else
  47.     {
  48.         res = True;
  49.         fclose(fd);
  50.     }
  51.     return res;
  52. }
  53.  
  54.  
  55.  
  56. void
  57. error(char *name)
  58. {/* prints error messages to report window */
  59.  
  60.     fprintf(stderr, "while scanning: ");
  61.     fprintf(stderr, "%s", name);
  62.     fprintf(stderr, "......skipping to next known token !\n");
  63.  
  64. }
  65.  
  66.  
  67.  
  68.  
  69. void
  70. load_it(char *fn)
  71. /* opening, creating, error handling, etc. */
  72. /* be sure, database is empty, all memory is given back */
  73. {
  74.     FILE           *fd;
  75.     int             t;    /* token */
  76.     float           c;
  77.     int         store_unit;
  78.  
  79.     if (file_exists(fn) == False)
  80.     {
  81.         leave_pick("ERROR - file not found.");
  82.         return;
  83.     }
  84.     /* open file */
  85.     fd = fopen(fn, "r");
  86.     /* file pointer points to the beginning of this file */
  87.  
  88.     /* scan it ! */
  89.  
  90.     yyinitscan(fd); /* init scanner */
  91.  
  92.     t = TOK_BEGIN;    /* now a dummy */
  93.     while (t != TOK_END)
  94.     {
  95.  
  96.         buffer.textpos[0] = 'c';
  97.         buffer.textpos[1] = 'c';
  98.  
  99.         switch (t = yylex())
  100.         {
  101.  
  102.         case TOK_BEGIN:
  103.             if ((t = yylex()) == TOK_FLOAT)
  104.             {    /* the x dimension; not used ! */
  105.                 if ((t = yylex()) == TOK_FLOAT)
  106.                 {    /* the y-dimension; not used */
  107.                     if ((t = yylex()) == TOK_FLOAT)
  108.                     {    /* optional: reference
  109.                          * x-coordinate */
  110.                         xur = yyfloatval;
  111.                         if ((t = yylex()) == TOK_FLOAT)
  112.                         {    /* optional: reference
  113.                              * y-coordinate */
  114.                             yur = yyfloatval;
  115.                             break;
  116.                         } else
  117.                             error("missing y-coordinate !\n");
  118.                     }
  119.                 } else
  120.                     error("missing y-dimension !\n");
  121.             } else
  122.                 error("float/int expected (dimension)!\n");
  123.  
  124.         case TOK_PUT:
  125.             if ((t = yylex()) == TOK_FLOAT)
  126.             {
  127.                 buffer.xpos = yyfloatval;
  128.                 if ((t = yylex()) == TOK_FLOAT)
  129.                 {
  130.                     buffer.ypos = yyfloatval;
  131.                     break;
  132.                 } else
  133.                     error("missing y-coordinate of PUT-command.\n");
  134.             } else
  135.                 error("missing x-coordinate of PUT-command.\n");
  136.  
  137.         case TOK_TEXT:
  138.             strcpy(buffer.text, yystrval);
  139.             buffer.textpos[1] = 'b';
  140.             buffer.textpos[1] = 'l';
  141.             read_message();
  142.             break;
  143.  
  144.         case TOK_FRAMEBOX:
  145.             if ((t = yylex()) == TOK_FLOAT)
  146.             {
  147.                 buffer.hpos = yyfloatval;
  148.                 if ((t = yylex()) == TOK_FLOAT)
  149.                 {
  150.                     buffer.vpos = yyfloatval;
  151.                     if ((t = yylex()) == TOK_LETTERS_OPT)
  152.                     {
  153.                         buffer.textpos[0] = yystrval[0];
  154.                         buffer.textpos[1] = yystrval[1];
  155.                     } else
  156.                     {
  157.                         buffer.textpos[0] = 'c';
  158.                         buffer.textpos[1] = 'c';
  159.                     }
  160.                     if ((t = yylex()) == TOK_TEXT)
  161.                     {
  162.                         strcpy(buffer.text, yystrval);
  163.                         read_framebox();
  164.                         break;
  165.                     } else
  166.                         error("text expected...\n");
  167.                 } else
  168.                     error("height of framebox not found.\n");
  169.             } else
  170.                 error("width of framebox not found.\n");
  171.  
  172.         case TOK_MAKEBOX:
  173.             if ((t = yylex()) == TOK_FLOAT)
  174.             {
  175.                 buffer.hpos = yyfloatval;    /* dummy; not used here */
  176.                 if ((t = yylex()) == TOK_FLOAT)
  177.                 {
  178.                     buffer.vpos = yyfloatval;    /* dummy; not used here */
  179.                     if ((t = yylex()) == TOK_LETTERS_OPT)
  180.                     {
  181.                         buffer.textpos[0] = yystrval[0];
  182.                         buffer.textpos[1] = yystrval[1];
  183.                     } else
  184.                     {
  185.                         buffer.textpos[0] = 'c';
  186.                         buffer.textpos[1] = 'c';
  187.                     }
  188.                     if ((t = yylex()) == TOK_TEXT)
  189.                     {
  190.                         strcpy(buffer.text, yystrval);
  191.                         read_message();
  192.                         break;
  193.                     } else
  194.                         error("text expected...\n");
  195.                 } else
  196.                     error("height of box not found.\n");
  197.             } else
  198.                 error("width of box not found.\n");
  199.  
  200.         case TOK_DASHBOX:
  201.             if ((t = yylex()) == TOK_FLOAT)
  202.             {    /* read dash-length */
  203.                 buffer.dash_length = yyfloatval;
  204.             } else
  205.                 error("missing dashlength...\n");
  206.             if ((t = yylex()) == TOK_FLOAT)
  207.             {
  208.                 buffer.hpos = yyfloatval;
  209.                 if ((t = yylex()) == TOK_FLOAT)
  210.                 {
  211.                     buffer.vpos = yyfloatval;
  212.                     if ((t = yylex()) == TOK_LETTERS_OPT)
  213.                     {
  214.                         buffer.textpos[0] = yystrval[0];
  215.                         buffer.textpos[1] = yystrval[1];
  216.                     } else
  217.                     {
  218.                         buffer.textpos[0] = 'c';
  219.                         buffer.textpos[1] = 'c';
  220.                     }
  221.                     if ((t = yylex()) == TOK_TEXT)
  222.                     {
  223.                         strcpy(buffer.text, yystrval);
  224.                         read_dashbox();
  225.                         break;
  226.                     } else
  227.                         error("dashbox: text expected...\n");
  228.                 } else
  229.                     error("height of dashbox not found.\n");
  230.             } else
  231.                 error("width of dashbox not found.\n");
  232.  
  233.  
  234.         case TOK_LINE:
  235.             if ((t = yylex()) == TOK_FLOAT)
  236.             {
  237.                 buffer.hpos = yyfloatval;
  238.                 if ((t = yylex()) == TOK_FLOAT)
  239.                 {
  240.                     buffer.vpos = yyfloatval;
  241.                     if ((t = yylex()) == TOK_FLOAT)
  242.                     {
  243.                         buffer.dash_length = yyfloatval;    /* line length !!! */
  244.                         read_line();
  245.                         break;
  246.                     } else
  247.                         error("length of line not specified...\n");
  248.                 } else
  249.                     error("line slope error (denominator) !\n");
  250.             } else
  251.                 error("line slope error (nominator) !\n");
  252.  
  253.         case TOK_VECTOR:
  254.             if ((t = yylex()) == TOK_FLOAT)
  255.             {
  256.                 buffer.hpos = yyfloatval;
  257.                 if ((t = yylex()) == TOK_FLOAT)
  258.                 {
  259.                     buffer.vpos = yyfloatval;
  260.                     if ((t = yylex()) == TOK_FLOAT)
  261.                     {
  262.                         buffer.dash_length = yyfloatval;    /* vector length !!! */
  263.                         read_vector();
  264.                         break;
  265.                     } else
  266.                         error("length of vector not specified...\n");
  267.                 } else
  268.                     error("vector slope error (denominator) !\n");
  269.             } else
  270.                 error("vector slope error (nominator) !\n");
  271.  
  272.         case TOK_CIRCLE:
  273.             if ((t = yylex()) == TOK_FLOAT)
  274.             {
  275.                 buffer.radius = (int) yyfloatval;
  276.                 read_circle();
  277.                 break;
  278.             } else
  279.                 error("missing circle diameter.\n");
  280.  
  281.         case TOK_CIRCLE_AST:
  282.             if ((t = yylex()) == TOK_FLOAT)
  283.             {
  284.                 buffer.radius = (int) yyfloatval;
  285.                 read_disc();
  286.                 break;
  287.             } else
  288.                 error("missing (filled) circle diameter.\n");
  289.  
  290.         case TOK_OVAL:
  291.             if ((t = yylex()) == TOK_FLOAT)
  292.             {
  293.                 buffer.hpos = yyfloatval;
  294.                 if ((t = yylex()) == TOK_FLOAT)
  295.                 {
  296.                     buffer.vpos = yyfloatval;
  297.                     read_oval();
  298.                     break;
  299.                 } else
  300.                     error("height of oval not found.\n");
  301.             } else
  302.                 error("width of oval not found.\n");
  303.  
  304.         case TOK_RULE: /* werte werden direkt im richtigen masstab gespeichert... */
  305.             if ((t = yylex()) == TOK_FLOAT)
  306.             {
  307.               buffer.hpos = yyfloatval;
  308.               t=yylex(); /* entweder es kommt eine einheit oder "unitlength" */
  309.               if (t!=TOK_DIM_UNITLENGTH) /* 1=pt 2=cm 3=mm 4=pc 5=in */
  310.               {
  311.                 store_unit=unit;
  312.                 switch (t){
  313.                  case TOK_DIM_PT  :    unit=1;  
  314.                              break;     
  315.                  case TOK_DIM_CM  : unit=2;
  316.                              break;     
  317.                  case TOK_DIM_MM  : unit=3;
  318.                              break; 
  319.                  case TOK_DIM_PC  : unit=4;
  320.                              break;    
  321.                  case TOK_DIM_IN  : unit=5;
  322.                              break;
  323.                  default:error("See LaTeX manual for proper use of the rule command...\n");
  324.                           break;
  325.                  } /* switch */   
  326.                  buffer.hpos=compute_length(buffer.hpos); 
  327.                  unit=store_unit;
  328.               } else buffer.hpos=compute_length(buffer.hpos); 
  329.     
  330.                 if ((t = yylex()) == TOK_FLOAT)
  331.                 {
  332.                     buffer.vpos = yyfloatval;
  333.                     t=yylex(); /* s.o. */
  334.                     if (t!=TOK_DIM_UNITLENGTH) /* 1=pt 2=cm 3=mm 4=pc 5=in */
  335.                     {
  336.                         store_unit=unit;
  337.                         switch (t){
  338.                         case TOK_DIM_PT  :    unit=1;  
  339.                                          break;     
  340.                              case TOK_DIM_CM  :     unit=2;
  341.                                          break;     
  342.                              case TOK_DIM_MM  :     unit=3;
  343.                                          break; 
  344.                              case TOK_DIM_PC  :     unit=4;
  345.                                          break;    
  346.                              case TOK_DIM_IN  :     unit=5;
  347.                                          break;
  348.                              default:error("See LaTeX manual for proper use of the rule command...\n");
  349.                                      break;
  350.                              } /* switch */ 
  351.                              buffer.vpos=compute_length(buffer.vpos);
  352.                              unit=store_unit;  
  353.                     } else buffer.vpos=compute_length(buffer.vpos); 
  354.                     
  355.                         
  356.                             read_filledbox(); /* .hpos und .vpos sind bereits im richtigen format */
  357.                             break; /* switch,case global */
  358.                             
  359.                 
  360.                 } else
  361.                     error("height of filled box (rule) not found.\n");
  362.             } else
  363.                 error("width of filled Box (rule) not found.\n");
  364.  
  365.         case TOK_BEZIER:
  366.             if ((t = yylex()) == TOK_FLOAT) buffer.dash_length=yyfloatval;
  367.             /* the number of points, the curve consists of, is stored in <dash_length> */
  368.             /* no further use ! */
  369.             if ((t = yylex()) == TOK_FLOAT)
  370.             {
  371.               buffer.xpos = yyfloatval;
  372.               if ((t = yylex()) == TOK_FLOAT)
  373.               {
  374.                  buffer.ypos = yyfloatval;
  375.                  if ((t = yylex()) == TOK_FLOAT)
  376.                  {
  377.                     buffer.hpos = yyfloatval;
  378.                 if ((t = yylex()) == TOK_FLOAT)
  379.                   {
  380.                         buffer.vpos = yyfloatval;
  381.                         if ((t = yylex()) == TOK_FLOAT)
  382.                         {
  383.                           buffer.sxpos = yyfloatval;
  384.                       if ((t = yylex()) == TOK_FLOAT)
  385.                         {
  386.                              buffer.sypos = yyfloatval;
  387.                      read_bezier();
  388.                      break;
  389.                       } else
  390.                            error("missing last number.\n");
  391.                    } else
  392.                        error("missing fifth number.\n");
  393.                 } else
  394.                     error("missing fourth number.\n");
  395.                  } else
  396.                  error("missing third number.\n");        
  397.               } else
  398.                   error("missing second number.\n");
  399.             } else
  400.                 error("missing first number.\n");
  401.  
  402.         case TOK_UNITLENGTH:
  403.             ulen = yyfloatval;
  404.             switch (t = yylex())
  405.             {
  406.             case TOK_DIM_PT:
  407.                 unit = 1;
  408.                 break;
  409.             case TOK_DIM_IN:
  410.                 unit = 2;
  411.                 break;
  412.             case TOK_DIM_CM:
  413.                 unit = 3;
  414.                 break;
  415.             case TOK_DIM_MM:
  416.                 unit = 4;
  417.                 break;
  418.             case TOK_DIM_PC:
  419.                 unit = 5;
  420.                 break;
  421.             default:
  422.                 error("unit not found !\n");
  423.                 break;
  424.             }
  425.             break;
  426.  
  427.  
  428.         default:
  429.             break;
  430.  
  431.  
  432.  
  433.         }    /* switch */
  434.  
  435.     }    /* while */
  436.  
  437.  
  438.     fclose(fd);
  439.  
  440.  
  441. }
  442.  
  443.  
  444.  
  445. float
  446. compute_length(float inp)
  447. {
  448.     /* int unit: 1=pt 2=in 3=cm 4=mm 5=pc */
  449.  
  450.  
  451.  
  452.     float           outp;
  453.     switch (unit)
  454.     {
  455.     case 1:
  456.         outp = inp * ulen;    /* 1pt remains 1pt */
  457.         /* unitlength=1.0pt */
  458.         break;
  459.     case 2:
  460.         outp = inp * ulen * 72.27;    /* 1inch=72.27pt */
  461.         /* unitlength=1.0pt */
  462.         break;
  463.     case 3:
  464.         outp = inp * ulen * 28.35;    /* 1cm=28.35pt */
  465.         /* unitlength=1.0pt */
  466.         break;
  467.     case 4:
  468.         outp = inp * ulen * 2.835;    /* 1mm=2.835pt */
  469.         /* unitlength=1.0pt */
  470.         break;
  471.     case 5:
  472.         outp = inp * ulen * 12;            /* 1pica=12pt */
  473.         /* unitlength=1.0pt */
  474.         break;
  475.  
  476.     default:
  477.         outp = 1;    /* dummy */
  478.         fprintf(stderr, "in function compute_length: default-case must not occur !!!\n\n");
  479.         break;
  480.     }
  481.  
  482.     return outp;
  483.  
  484. }
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492. /* the following read_xxx - routines insert a new object into the database */
  493. /* and then return to the scanner... */
  494.  
  495. void
  496. read_framebox()
  497. {
  498.     struct fig3    *drei = (struct fig3 *) malloc(sizeof(framedBox));
  499.     /* fill the struct */
  500.     drei->x = compute_length(buffer.xpos);
  501.     drei->y = compute_length(buffer.ypos);
  502.  
  503.     drei->h = drei->x + compute_length(buffer.hpos);
  504.     drei->v = drei->y + compute_length(buffer.vpos);
  505.  
  506.     drei->text = (char *) malloc(strlen(buffer.text) + 1);
  507.     strcpy(drei->text, buffer.text);
  508.  
  509.     if (
  510.         (buffer.textpos[0] != 'b') &&
  511.         (buffer.textpos[0] != 't') &&
  512.         (buffer.textpos[0] != 'l') &&
  513.         (buffer.textpos[0] != 'r')
  514.         )
  515.         buffer.textpos[0] = '\0';
  516.  
  517.     if (
  518.         (buffer.textpos[1] != 'b') &&
  519.         (buffer.textpos[1] != 't') &&
  520.         (buffer.textpos[1] != 'l') &&
  521.         (buffer.textpos[1] != 'r')
  522.         )
  523.         buffer.textpos[1] = '\0';
  524.  
  525.     drei->textpos[0] = buffer.textpos[0];
  526.     drei->textpos[1] = buffer.textpos[1];
  527.     drei->next = NULL;
  528.  
  529.     /* use internal coordinate system */
  530.     drei->y = oldy(drei->y);
  531.     drei->v = oldy(drei->v);
  532.  
  533.     norm_rectangle(&drei->x, &drei->y, &drei->h, &drei->v);
  534.  
  535.     /* insert the struct into database */
  536.  
  537.     if (framedBox_start == NULL)
  538.     {
  539.         framedBox_start = drei;
  540.         framedBox_curr = drei;
  541.     } else
  542.     {
  543.         framedBox_curr->next = drei;
  544.         framedBox_curr = drei;
  545.     }
  546.  
  547. }
  548.  
  549. void
  550. read_dashbox()
  551. {
  552.     struct fig4    *vier = (struct fig4 *) malloc(sizeof(dashedBox));
  553.     /* fill the struct */
  554.     vier->x = compute_length(buffer.xpos);
  555.     vier->y = compute_length(buffer.ypos);
  556.  
  557.     vier->h = vier->x + compute_length(buffer.hpos);
  558.     vier->v = vier->y + compute_length(buffer.vpos);
  559.  
  560.     vier->text = (char *) malloc(strlen(buffer.text) + 1);
  561.     strcpy(vier->text, buffer.text);
  562.  
  563.     if (
  564.         (buffer.textpos[0] != 'b') &&
  565.         (buffer.textpos[0] != 't') &&
  566.         (buffer.textpos[0] != 'l') &&
  567.         (buffer.textpos[0] != 'r')
  568.         )
  569.         buffer.textpos[0] = '\0';
  570.  
  571.     if (
  572.         (buffer.textpos[1] != 'b') &&
  573.         (buffer.textpos[1] != 't') &&
  574.         (buffer.textpos[1] != 'l') &&
  575.         (buffer.textpos[1] != 'r')
  576.         )
  577.         buffer.textpos[1] = '\0';
  578.  
  579.     vier->textpos[0] = buffer.textpos[0];
  580.     vier->textpos[1] = buffer.textpos[1];
  581.  
  582.     vier->dashlength = compute_length(buffer.dash_length);
  583.  
  584.     vier->next = NULL;
  585.  
  586.     /* use internal coordinate system */
  587.     vier->y = oldy(vier->y);
  588.     vier->v = oldy(vier->v);
  589.  
  590.     norm_rectangle(&vier->x, &vier->y, &vier->h, &vier->v);
  591.  
  592.     /* insert the struct into database */
  593.  
  594.     if (dashedBox_start == NULL)
  595.     {
  596.         dashedBox_start = vier;
  597.         dashedBox_curr = vier;
  598.     } else
  599.     {
  600.         dashedBox_curr->next = vier;
  601.         dashedBox_curr = vier;
  602.     }
  603. }
  604.  
  605. void
  606. read_filledbox()
  607. {
  608.  /* buffer.hpos und buffer.vpos sind bereits waehrend des scannens ins richtige format konvertiert worden */
  609.  
  610.  
  611.     struct fig2    *zwei = (struct fig2 *) malloc(sizeof(filledBox));
  612.     /* fill the struct */
  613.     zwei->x = compute_length(buffer.xpos);
  614.     zwei->y = compute_length(buffer.ypos);
  615.  
  616.     zwei->h = zwei->x + buffer.hpos;
  617.     zwei->v = zwei->y + buffer.vpos;
  618.  
  619.     zwei->next = NULL;
  620.  
  621.     /* use internal coordinate system */
  622.     zwei->y = oldy(zwei->y);
  623.     zwei->v = oldy(zwei->v);
  624.  
  625.     norm_rectangle(&zwei->x, &zwei->y, &zwei->h, &zwei->v);
  626.  
  627.     /* insert the struct into database */
  628.  
  629.     if (filledBox_start == NULL)
  630.     {
  631.         filledBox_start = zwei;
  632.         filledBox_curr = zwei;
  633.     } else
  634.     {
  635.         filledBox_curr->next = zwei;
  636.         filledBox_curr = zwei;
  637.     }
  638. }
  639.  
  640. void
  641. read_line()
  642. {
  643.     struct fig2    *zwei = (struct fig2 *) malloc(sizeof(strich));
  644.     /* fill the struct */
  645.     zwei->x = compute_length(buffer.xpos);
  646.     zwei->y = compute_length(buffer.ypos);
  647.  
  648.     /* the vector */
  649.     zwei->h = buffer.hpos;
  650.     zwei->v = buffer.vpos;
  651.  
  652.     compute_end_coords(zwei->x, zwei->y, &zwei->h, &zwei->v, compute_length(buffer.dash_length));
  653.  
  654.     zwei->next = NULL;
  655.  
  656.     /* use internal coordinate system */
  657.     zwei->y = oldy(zwei->y);
  658.     zwei->v = oldy(zwei->v);
  659.  
  660.  
  661.     /* insert the struct into database */
  662.  
  663.     if (strich_start == NULL)
  664.     {
  665.         strich_start = zwei;
  666.         strich_curr = zwei;
  667.     } else
  668.     {
  669.         strich_curr->next = zwei;
  670.         strich_curr = zwei;
  671.     }
  672. }
  673.  
  674. void
  675. read_vector()
  676. {
  677.     struct fig2    *zwei = (struct fig2 *) malloc(sizeof(pfeil));
  678.     /* fill the struct */
  679.     zwei->x = compute_length(buffer.xpos);
  680.     zwei->y = compute_length(buffer.ypos);
  681.  
  682.     /* the vector */
  683.     zwei->h = buffer.hpos;
  684.     zwei->v = buffer.vpos;
  685.  
  686.     compute_end_coords(zwei->x, zwei->y, &zwei->h, &zwei->v, compute_length(buffer.dash_length));
  687.  
  688.     zwei->next = NULL;
  689.  
  690.     /* use internal coordinate system */
  691.     zwei->y = oldy(zwei->y);
  692.     zwei->v = oldy(zwei->v);
  693.  
  694.     /* insert the struct into database */
  695.  
  696.     if (pfeil_start == NULL)
  697.     {
  698.         pfeil_start = zwei;
  699.         pfeil_curr = zwei;
  700.     } else
  701.     {
  702.         pfeil_curr->next = zwei;
  703.         pfeil_curr = zwei;
  704.     }
  705. }
  706.  
  707.  
  708. void
  709. read_circle()
  710. {
  711.     struct fig2    *zwei = (struct fig2 *) malloc(sizeof(kreis));
  712.     /* fill the struct */
  713.     zwei->x = compute_length(buffer.xpos);
  714.     zwei->y = compute_length(buffer.ypos);
  715.     zwei->radius = (int) compute_length((float) buffer.radius / 2);
  716.  
  717.     zwei->next = NULL;
  718.  
  719.     /* use internal coordinate system */
  720.     zwei->y = oldy(zwei->y);
  721.  
  722.     /* insert the struct into database */
  723.  
  724.     if (kreis_start == NULL)
  725.     {
  726.         kreis_start = zwei;
  727.         kreis_curr = zwei;
  728.     } else
  729.     {
  730.         kreis_curr->next = zwei;
  731.         kreis_curr = zwei;
  732.     }
  733. }
  734.  
  735. void
  736. read_disc()
  737. {
  738.     struct fig2    *zwei = (struct fig2 *) malloc(sizeof(disc));
  739.     /* fill the struct */
  740.     zwei->x = compute_length(buffer.xpos);
  741.     zwei->y = compute_length(buffer.ypos);
  742.     zwei->radius = (int) compute_length((float) buffer.radius / 2);
  743.  
  744.     zwei->next = NULL;
  745.  
  746.     /* use internal coordinate system */
  747.     zwei->y = oldy(zwei->y);
  748.  
  749.     /* insert the struct into database */
  750.  
  751.     if (disc_start == NULL)
  752.     {
  753.         disc_start = zwei;
  754.         disc_curr = zwei;
  755.     } else
  756.     {
  757.         disc_curr->next = zwei;
  758.         disc_curr = zwei;
  759.     }
  760. }
  761.  
  762. void
  763. read_oval()
  764. {
  765.     struct fig1    *eins = (struct fig1 *) malloc(sizeof(oval));
  766.     /* fill the struct */
  767.     eins->x = compute_length(buffer.xpos);
  768.     eins->y = compute_length(buffer.ypos);
  769.  
  770.     eins->h = compute_length(buffer.hpos);
  771.     eins->v = compute_length(buffer.vpos);
  772.  
  773.     (eins->x) -= (eins->h / 2);
  774.     (eins->y) -= (eins->v / 2);
  775.  
  776.     eins->h = eins->h + eins->x;
  777.     eins->v = eins->v + eins->y;
  778.  
  779.     eins->next = NULL;
  780.  
  781.     /* use internal coordinate system */
  782.     eins->y = oldy(eins->y);
  783.     eins->v = oldy(eins->v);
  784.  
  785.     norm_rectangle(&eins->x, &eins->y, &eins->h, &eins->v);
  786.  
  787.     /* insert the struct into database */
  788.  
  789.     if (oval_start == NULL)
  790.     {
  791.         oval_start = eins;
  792.         oval_curr = eins;
  793.     } else
  794.     {
  795.         oval_curr->next = eins;
  796.         oval_curr = eins;
  797.     }
  798. }
  799.  
  800. void
  801. read_message()
  802. {
  803.   int lenn=81;
  804.  
  805.     struct fig5    *fuenf = (struct fig5 *) malloc(sizeof(message));
  806.     /* fill the struct */
  807.  
  808.     if (1+strlen(buffer.text)>lenn) lenn=1+strlen(buffer.text);
  809.  
  810.     fuenf->x = compute_length(buffer.xpos);
  811.     fuenf->y = compute_length(buffer.ypos);
  812.  
  813.     fuenf->text = (char *) malloc(lenn);
  814.     strcpy(fuenf->text, buffer.text);
  815.  
  816.     if (
  817.         (buffer.textpos[0] != 'b') &&
  818.         (buffer.textpos[0] != 't') &&
  819.         (buffer.textpos[0] != 'l') &&
  820.         (buffer.textpos[0] != 'r')
  821.         )
  822.         buffer.textpos[0] = 'c';
  823.  
  824.     if (
  825.         (buffer.textpos[1] != 'b') &&
  826.         (buffer.textpos[1] != 't') &&
  827.         (buffer.textpos[1] != 'l') &&
  828.         (buffer.textpos[1] != 'r')
  829.         )
  830.         buffer.textpos[1] = 'c';
  831.  
  832.     fuenf->textpos[0] = buffer.textpos[0];
  833.     fuenf->textpos[1] = buffer.textpos[1];
  834.  
  835.     fuenf->next = NULL;
  836.  
  837.     /* use internal coordinate system */
  838.     fuenf->y = oldy(fuenf->y);
  839.  
  840.     /* insert the struct into database */
  841.  
  842.     if (message_start == NULL)
  843.     {
  844.         message_start = fuenf;
  845.         message_curr = fuenf;
  846.     } else
  847.     {
  848.         message_curr->next = fuenf;
  849.         message_curr = fuenf;
  850.     }
  851. }
  852.  
  853. void
  854. read_bezier()
  855. {
  856.     struct fig6    *six = (struct fig6 *) malloc(sizeof(bezier));
  857.     /* fill the struct */
  858.     six->ax = compute_length(buffer.xpos);
  859.     six->ay = compute_length(buffer.ypos);
  860.  
  861.     six->sx = compute_length(buffer.hpos);
  862.     six->sy = compute_length(buffer.vpos);
  863.  
  864.     six->ex = compute_length(buffer.sxpos);
  865.     six->ey = compute_length(buffer.sypos);
  866.  
  867.     six->next = NULL;
  868.  
  869.     /* use internal coordinate system */
  870.     six->ay = oldy(six->ay);
  871.     six->ey = oldy(six->ey);
  872.     six->sy = oldy(six->sy);
  873.  
  874.     /* insert the struct into database */
  875.  
  876.     if (bezier_start == NULL)
  877.     {
  878.         bezier_start = six;
  879.         bezier_curr = six;
  880.     } else
  881.     {
  882.         bezier_curr->next = six;
  883.         bezier_curr = six;
  884.     }
  885. }
  886.  
  887. void
  888. compute_end_coords(float x, float y, float *h, float *v, float len)
  889. {
  890.     int             sgn;
  891.     float           ziel, lambda;
  892.     /* vertical ? */
  893.     if ((*h) == 0)
  894.     {
  895.         sgn = ((*v) < 0) ? -1 : 1;
  896.         (*v) = y + (float) sgn *len;
  897.         (*h) = x;
  898.     } else
  899.     {
  900.         len = ((*h) > 0) ? len : -len;
  901.         ziel = x + len;
  902.         lambda = (ziel - x) / (*h);
  903.         (*h) = ziel;
  904.         (*v) = y + lambda * (*v);
  905.     }
  906.     return;
  907. }
  908.  
  909.  
  910.  
  911.  
  912.  
  913. void
  914. trans_it(char *fn)
  915. {
  916.     char            name[256];
  917.     FILE           *fd;
  918.     int             i;
  919.     float           xdim, ydim;
  920.  
  921.     dim_x_max = 0;
  922.     dim_x_min = 999;
  923.     dim_y_max = 0;
  924.     dim_y_min = 999;
  925.  
  926.     if (file_exists(fn) == True)
  927.     {
  928.         strcpy(name, fn);
  929.         strcat(name, ".old");
  930.         rename(fn, name);
  931.     }
  932.     fd = fopen(fn, "w+");
  933.     manage_line(0, fd);
  934.     manage_vector(0, fd);
  935.     manage_filled(0, fd);
  936.     manage_framed(0, fd);
  937.     manage_dashed(0, fd);
  938.     manage_kreis(0, fd);
  939.     manage_disc(0, fd);
  940.     manage_oval(0, fd);
  941.     manage_text(0, fd);
  942.     manage_bezier(0, fd);
  943.  
  944.     xdim = dim_x_max - dim_x_min;
  945.     ydim = dim_y_max - dim_y_min;
  946.     xur = (xur == 0.0) ? dim_x_min : xur;
  947.     yur = (yur == 0.0) ? newy(dim_y_max) : yur;
  948.  
  949.     
  950.     if ((dina4 == True) && (xdim > 300))
  951.     {
  952.         fprintf(fd, "%% ...images, whose extensions are to large for the\n");
  953.         fprintf(fd, "%% current style, can be centered with one of the following\n");
  954.         fprintf(fd, "%% modifications\n");
  955.         fprintf(fd, "%%    -  if there is only one page to translate:\n");
  956.         fprintf(fd, "%%       in the preamble: \\setlength{\\textheight}{%ipt}\n", y_A4_max);
  957.         fprintf(fd, "%%                        \\setlength{\\textwidth}{%ipt}\n", x_A4_max);
  958.         fprintf(fd, "%%    -  use the 2nd coordinate of the \\picture-command to adjust\n");
  959.         fprintf(fd, "%%       your image! X-Dimension is %3.2f, Y-Dimension is %3.2f\n", xdim, ydim);
  960.         fprintf(fd, "%% small images can be centered with the 'center'-environment.\n");
  961.     }
  962.     /* write header */
  963.  
  964.     
  965.  
  966.     fprintf(fd, "\\unitlength=1.0pt\n");
  967.     if (dina4 == True)
  968.         fprintf(fd, "\\begin{center}\n");
  969.     fprintf(fd, "\\begin{picture}(%3.2f,%3.2f)(%3.2f,%3.2f)\n",
  970.         xdim, ydim, xur, yur);
  971.  
  972.  
  973.     /* objects */
  974.  
  975.     manage_line(1, fd);
  976.     manage_vector(1, fd);
  977.     manage_filled(1, fd);
  978.     manage_framed(1, fd);
  979.     manage_dashed(1, fd);
  980.     manage_kreis(1, fd);
  981.     manage_disc(1, fd);
  982.     manage_oval(1, fd);
  983.     manage_text(1, fd);
  984.     manage_bezier(1, fd);
  985.  
  986.     fprintf(fd, "\\end{picture}\n");
  987.  
  988.     if (dina4 == True)
  989.         fprintf(fd, "\\end{center}\n");
  990.  
  991.     
  992.     fclose(fd);
  993.  
  994. }
  995.  
  996.  
  997. void
  998. dimension_update(float x, float y)
  999. {
  1000.     dim_x_min = (x < dim_x_min) ? x : dim_x_min;
  1001.     dim_x_max = (x > dim_x_max) ? x : dim_x_max;
  1002.  
  1003.     dim_y_min = (y < dim_y_min) ? y : dim_y_min;
  1004.     dim_y_max = (y > dim_y_max) ? y : dim_y_max;
  1005.  
  1006. /*
  1007.     if (dim_y_min < 0)
  1008.         dim_y_min = 0;
  1009.     if (dim_y_max > y_A4_max)
  1010.         dim_y_max = y_A4_max;
  1011.     if (dim_x_min < 0)
  1012.         dim_x_min = 0;
  1013.     if (dim_x_max > x_A4_max)
  1014.         dim_x_max = x_A4_max;
  1015. */
  1016.  
  1017. }
  1018.  
  1019.  
  1020. float
  1021. newy(float y)
  1022. {/* compute new y-coordinate for LaTeX' coord.-system */
  1023.  
  1024.     return y_A4_max - y;
  1025. }
  1026.  
  1027. float
  1028. oldy(float y)
  1029. {/* does the opposite... */
  1030.  
  1031.     return newy(y);
  1032. }
  1033.  
  1034.  
  1035. void
  1036. get_line_info(float x, float y, float h, float v, int *x_slp, int *y_slp, float *len)
  1037. {
  1038.     int             t, a, b, i;
  1039.  
  1040.  
  1041.     if (line_slope == 0)
  1042.     {    /* unlimited slopes */
  1043.         y = newy(y);
  1044.         v = newy(v);
  1045.  
  1046.         if ((abs((int) (h - x)) != 0) && (abs((int) (v - y)) != 0))
  1047.         {    /* not horizontal; not vertical */
  1048.             a = abs((int) (h - x));
  1049.             b = abs((int) (v - y));
  1050.             t = ggt(a, b);
  1051.  
  1052.             a = a / t;
  1053.             b = b / t;
  1054.             a = (x < h) ? a : -a;
  1055.             b = (y < v) ? b : -b;
  1056.             (*x_slp) = a;
  1057.             (*y_slp) = b;
  1058.             (*len) = (x < h) ? (h - x) : (x - h);
  1059.         } else
  1060.         {
  1061.             if ((abs((int) (h - x)) != 0))
  1062.             {    /* horizontal line */
  1063.                 (*x_slp) = (x < h) ? 1 : -1;
  1064.                 (*y_slp) = 0;
  1065.                 (*len) = (x < h) ? (h - x) : (x - h);
  1066.             } else
  1067.             {    /* vertical line */
  1068.                 (*x_slp) = 0;
  1069.                 (*y_slp) = (y < v) ? 1 : -1;
  1070.                 (*len) = (y < v) ? (v - y) : (y - v);
  1071.             }
  1072.         }
  1073.     }
  1074.     /* line_slope unlimited ! */
  1075.     else
  1076.     {    /* normal LaTex slopes... */
  1077.         a = (int) h;
  1078.         b = (int) v;
  1079.         i = valid_line_coords((int) x, (int) y, &a, &b);
  1080.  
  1081.  
  1082.         /* use LaTeX coordinate-system: */
  1083.         y = newy(y);
  1084.         v = newy(v);
  1085.  
  1086.         /* horizontal, vertical line ? */
  1087.  
  1088.         if (abs((int) (v - y)) == 0)
  1089.         {    /* horizontal */
  1090.             (*x_slp) = (x < h) ? 1 : -1;
  1091.             (*y_slp) = 0;
  1092.             (*len) = (x < h) ? (h - x) : (x - h);
  1093.         } else if (abs((int) (h - x)) == 0)
  1094.         {    /* vertical */
  1095.             (*y_slp) = (y < v) ? 1 : -1;
  1096.             (*x_slp) = 0;
  1097.             (*len) = (y < v) ? (v - y) : (y - v);
  1098.         } else
  1099.         {    /* normal line */
  1100.             (*x_slp) = (x < h) ? l_slope[i][1] : -l_slope[i][1];
  1101.             (*y_slp) = (y < v) ? l_slope[i][2] : -l_slope[i][2];
  1102.             (*len) = (x < h) ? (h - x) : (x - h);
  1103.         }
  1104.     }    /* else */
  1105.  
  1106.     /* (*len)+=1.0; */
  1107.  
  1108. }
  1109.  
  1110.  
  1111.  
  1112.  
  1113. void
  1114. get_vector_info(float x, float y, float h, float v, int *x_slp, int *y_slp, float *len)
  1115. {
  1116.     int             t, a, b, i;
  1117.  
  1118.  
  1119.     if (arrow_slope == 0)
  1120.     {    /* unlimited slopes */
  1121.         y = newy(y);
  1122.         v = newy(v);
  1123.  
  1124.         if ((abs((int) (h - x)) != 0) && (abs((int) (v - y)) != 0))
  1125.         {    /* not horizontal; not vertical */
  1126.             a = abs((int) (h - x));
  1127.             b = abs((int) (v - y));
  1128.             t = ggt(a, b);
  1129.  
  1130.             a = a / t;
  1131.             b = b / t;
  1132.             a = (x < h) ? a : -a;
  1133.             b = (y < v) ? b : -b;
  1134.             (*x_slp) = a;
  1135.             (*y_slp) = b;
  1136.             (*len) = (x < h) ? (h - x) : (x - h);
  1137.         } else
  1138.         {
  1139.             if ((abs((int) (h - x)) != 0))
  1140.             {    /* horizontal line */
  1141.                 (*x_slp) = (x < h) ? 1 : -1;
  1142.                 (*y_slp) = 0;
  1143.                 (*len) = (x < h) ? (h - x) : (x - h);
  1144.             } else
  1145.             {    /* vertical line */
  1146.                 (*x_slp) = 0;
  1147.                 (*y_slp) = (y < v) ? 1 : -1;
  1148.                 (*len) = (y < v) ? (v - y) : (y - v);
  1149.             }
  1150.         }
  1151.     }
  1152.     /* arrow_slope unlimited ! */
  1153.     else
  1154.     {    /* normal LaTeX slopes... */
  1155.         a = (int) h;
  1156.         b = (int) v;
  1157.         i = valid_vector_coords((int) x, (int) y, &a, &b);
  1158.  
  1159.  
  1160.  
  1161.         /* use LaTeX coordinate-system: */
  1162.         y = newy(y);
  1163.         v = newy(v);
  1164.  
  1165.         /* horizontal, vertical line ? */
  1166.  
  1167.         if (abs((int) (v - y)) == 0)
  1168.         {    /* horizontal */
  1169.             (*x_slp) = (x < h) ? 1 : -1;
  1170.             (*y_slp) = 0;
  1171.             (*len) = (x < h) ? (h - x) : (x - h);
  1172.         } else if (abs((int) (h - x)) == 0)
  1173.         {    /* vertical */
  1174.             (*y_slp) = (y < v) ? 1 : -1;
  1175.             (*x_slp) = 0;
  1176.             (*len) = (y < v) ? (v - y) : (y - v);
  1177.         } else
  1178.         {    /* normal line */
  1179.             (*x_slp) = (x < h) ? a_slope[i][1] : -a_slope[i][1];
  1180.             (*y_slp) = (y < v) ? a_slope[i][2] : -a_slope[i][2];
  1181.             (*len) = (x < h) ? (h - x) : (x - h);
  1182.         }
  1183.     }    /* else */
  1184.  
  1185.     /* (*len)+=1.0; */
  1186.  
  1187. }
  1188.  
  1189.  
  1190. void
  1191. manage_bezier(int what, FILE * fd)
  1192. {/* medium must be open */
  1193.  
  1194.   int pts;
  1195.  
  1196.  
  1197.     bezier_marker = bezier_start;
  1198.  
  1199.     if (bezier_start == NULL)
  1200.         return;
  1201.  
  1202.     while (True)
  1203.     {
  1204.  
  1205.         if (what == 0)
  1206.         {
  1207.             dimension_update(bezier_marker->ax, bezier_marker->ay);
  1208.             dimension_update(bezier_marker->ex, bezier_marker->ey);
  1209.             dimension_update(bezier_marker->sx, bezier_marker->sy);  
  1210.         } else if (what == 1)
  1211.         {
  1212.             pts=calc_distance((int)bezier_marker->ax, (int)bezier_marker->ay,
  1213.                        (int)bezier_marker->sx, (int)bezier_marker->sy)
  1214.                  +
  1215.                  calc_distance((int)bezier_marker->sx, (int)bezier_marker->sy,
  1216.                        (int)bezier_marker->ex, (int)bezier_marker->ey);
  1217.  
  1218.             fprintf(fd,"\\bezier%i(%03.2f,%03.2f)(%03.2f,%03.2f)(%03.2f,%03.2f)\n",pts,
  1219.                     bezier_marker->ax, newy(bezier_marker->ay),
  1220.                     bezier_marker->sx, newy(bezier_marker->sy),
  1221.                     bezier_marker->ex, newy(bezier_marker->ey));
  1222.         } else
  1223.         {
  1224.             bezier_marker->ax+=xmotion;
  1225.             bezier_marker->ay+=ymotion;
  1226.             bezier_marker->ex+=xmotion;
  1227.             bezier_marker->ey+=ymotion;
  1228.             bezier_marker->sx+=xmotion;
  1229.             bezier_marker->sy+=ymotion;
  1230.         }
  1231.  
  1232.         if (bezier_marker == bezier_curr)
  1233.             return;
  1234.  
  1235.         bezier_marker = bezier_marker->next;
  1236.  
  1237.     }
  1238. }
  1239.  
  1240.  
  1241.  
  1242. void
  1243. manage_line(int what, FILE * fd)
  1244. {/* medium must be open */
  1245.     int             x_slp, y_slp;
  1246.     float           len;
  1247.     strich_marker = strich_start;
  1248.  
  1249.     if (strich_start == NULL)
  1250.         return;
  1251.  
  1252.     while (True)
  1253.     {
  1254.  
  1255.         if (what == 0)
  1256.         {
  1257.             dimension_update(strich_marker->x, strich_marker->y);
  1258.             dimension_update(strich_marker->h, strich_marker->v);
  1259.         } else if (what==1)
  1260.         {
  1261.             get_line_info(strich_marker->x, strich_marker->y,
  1262.                       strich_marker->h, strich_marker->v,
  1263.                       &x_slp, &y_slp, &len);
  1264.             if ((line_length!=0) && (len<10.0)) len=10.0;
  1265.             fprintf(fd, "\\put(%03.2f,%03.2f){\\line(%i,%i){%03.2f}}\n",
  1266.                 strich_marker->x, newy(strich_marker->y), x_slp, y_slp, len);
  1267.         } else
  1268.         {
  1269.             strich_marker->x+=xmotion;
  1270.             strich_marker->h+=xmotion;
  1271.             strich_marker->y+=ymotion;
  1272.             strich_marker->v+=ymotion;
  1273.             /* all moved now */
  1274.         }
  1275.             
  1276.  
  1277.         if (strich_marker == strich_curr)
  1278.             return;
  1279.  
  1280.         strich_marker = strich_marker->next;
  1281.  
  1282.     }
  1283. }
  1284.  
  1285.  
  1286.  
  1287. void
  1288. manage_vector(int what, FILE * fd)
  1289. {/* medium must be open */
  1290.     int             x_slp, y_slp;
  1291.     float           len;
  1292.     pfeil_marker = pfeil_start;
  1293.  
  1294.     if (pfeil_start == NULL)
  1295.         return;
  1296.  
  1297.     while (True)
  1298.     {
  1299.  
  1300.         if (what == 0)
  1301.         {
  1302.             dimension_update(pfeil_marker->x, pfeil_marker->y);
  1303.             dimension_update(pfeil_marker->h, pfeil_marker->v);
  1304.         } else if (what == 1)
  1305.         {
  1306.             get_vector_info(pfeil_marker->x, pfeil_marker->y,
  1307.                     pfeil_marker->h, pfeil_marker->v,
  1308.                     &x_slp, &y_slp, &len);
  1309.             if ((line_length!=0) && (len<10.0)) len=10.0;
  1310.             fprintf(fd, "\\put(%03.2f,%03.2f){\\vector(%i,%i){%03.2f}}\n",
  1311.                 pfeil_marker->x, newy(pfeil_marker->y), x_slp, y_slp, len);
  1312.         } else
  1313.         {
  1314.             pfeil_marker->x+=xmotion;
  1315.             pfeil_marker->h+=xmotion;
  1316.             pfeil_marker->y+=ymotion;
  1317.             pfeil_marker->v+=ymotion;
  1318.             /* all moved now */
  1319.         }
  1320.  
  1321.         if (pfeil_marker == pfeil_curr)
  1322.             return;
  1323.  
  1324.         pfeil_marker = pfeil_marker->next;
  1325.  
  1326.     }
  1327. }
  1328.  
  1329.  
  1330.  
  1331. void
  1332. manage_filled(int what, FILE * fd)
  1333. {/* medium must be open */
  1334.  
  1335.  
  1336.     filledBox_marker = filledBox_start;
  1337.  
  1338.     if (filledBox_start == NULL)
  1339.         return;
  1340.  
  1341.     while (True)
  1342.     {
  1343.  
  1344.         /* normate rectangle */
  1345.         norm_rectangle(&filledBox_marker->x, &filledBox_marker->y,
  1346.                    &filledBox_marker->h, &filledBox_marker->v);
  1347.  
  1348.         if (what == 0)
  1349.         {
  1350.             dimension_update(filledBox_marker->x, filledBox_marker->y);
  1351.             dimension_update(filledBox_marker->h, filledBox_marker->v);
  1352.         } else if (what == 1)
  1353.         {
  1354.             fprintf(fd, "\\put(%03.2f,%03.2f){\\rule{%03.2f\\unitlength}{%03.2f\\unitlength}}\n",
  1355.                  filledBox_marker->x, newy(filledBox_marker->v),
  1356.                 (filledBox_marker->h - filledBox_marker->x),
  1357.                 (filledBox_marker->v - filledBox_marker->y));
  1358.         } else
  1359.         {
  1360.             filledBox_marker->x+=xmotion;
  1361.             filledBox_marker->h+=xmotion;
  1362.             filledBox_marker->y+=ymotion;
  1363.             filledBox_marker->v+=ymotion;
  1364.             /* all moved now */
  1365.         }
  1366.  
  1367.         if (filledBox_marker == filledBox_curr)
  1368.             return;
  1369.  
  1370.         filledBox_marker = filledBox_marker->next;
  1371.  
  1372.     }
  1373. }
  1374.  
  1375. void
  1376. manage_framed(int what, FILE * fd)
  1377. {/* medium must be open */
  1378.  
  1379.  
  1380.     framedBox_marker = framedBox_start;
  1381.  
  1382.     if (framedBox_start == NULL)
  1383.         return;
  1384.  
  1385.     while (True)
  1386.     {
  1387.  
  1388.         /* normate rectangle */
  1389.         norm_rectangle(&framedBox_marker->x, &framedBox_marker->y,
  1390.                    &framedBox_marker->h, &framedBox_marker->v);
  1391.  
  1392.         if (what == 0)
  1393.         {
  1394.             dimension_update(framedBox_marker->x, framedBox_marker->y);
  1395.             dimension_update(framedBox_marker->h, framedBox_marker->v);
  1396.         } else if (what == 1)
  1397.         {
  1398.             fprintf(fd, "\\put(%03.2f,%03.2f){\\framebox(%03.2f,%03.2f)",
  1399.                  framedBox_marker->x, newy(framedBox_marker->v),
  1400.                 (framedBox_marker->h - framedBox_marker->x),
  1401.                 (framedBox_marker->v - framedBox_marker->y));
  1402.  
  1403.             fprintf(fd, "[");
  1404.  
  1405.             switch (framedBox_marker->textpos[0])
  1406.             {
  1407.             case 'b':
  1408.                 fprintf(fd, "b");
  1409.                 break;
  1410.             case 't':
  1411.                 fprintf(fd, "t");
  1412.                 break;
  1413.             case 'l':
  1414.                 fprintf(fd, "l");
  1415.                 break;
  1416.             case 'r':
  1417.                 fprintf(fd, "r");
  1418.                 break;
  1419.             default:
  1420.                 fprintf(fd, "c");
  1421.                 break;
  1422.             }
  1423.  
  1424.             switch (framedBox_marker->textpos[1])
  1425.             {
  1426.             case 'b':
  1427.                 fprintf(fd, "b");
  1428.                 break;
  1429.             case 't':
  1430.                 fprintf(fd, "t");
  1431.                 break;
  1432.             case 'l':
  1433.                 fprintf(fd, "l");
  1434.                 break;
  1435.             case 'r':
  1436.                 fprintf(fd, "r");
  1437.                 break;
  1438.             default:
  1439.                 fprintf(fd, "c");
  1440.                 break;
  1441.             }
  1442.  
  1443.             framedBox_marker->text[strlen(framedBox_marker->text)] = '\0';
  1444.  
  1445.             fprintf(fd, "]{%s}}\n", framedBox_marker->text);
  1446.  
  1447.         } else
  1448.         {
  1449.             framedBox_marker->x+=xmotion;
  1450.             framedBox_marker->h+=xmotion;
  1451.             framedBox_marker->y+=ymotion;
  1452.             framedBox_marker->v+=ymotion;
  1453.             /* all moved now */
  1454.         }
  1455.  
  1456.         if (framedBox_marker == framedBox_curr)
  1457.             return;
  1458.  
  1459.         framedBox_marker = framedBox_marker->next;
  1460.  
  1461.     }
  1462. }
  1463.  
  1464.  
  1465. void
  1466. manage_dashed(int what, FILE * fd)
  1467. {/* medium must be open */
  1468.  
  1469.  
  1470.     dashedBox_marker = dashedBox_start;
  1471.  
  1472.     if (dashedBox_start == NULL)
  1473.         return;
  1474.  
  1475.     while (True)
  1476.     {
  1477.  
  1478.         /* normate rectangle */
  1479.         norm_rectangle(&dashedBox_marker->x, &dashedBox_marker->y,
  1480.                    &dashedBox_marker->h, &dashedBox_marker->v);
  1481.  
  1482.         if (what == 0)
  1483.         {
  1484.             dimension_update(dashedBox_marker->x, dashedBox_marker->y);
  1485.             dimension_update(dashedBox_marker->h, dashedBox_marker->v);
  1486.         } else if (what == 1)
  1487.         {
  1488.             fprintf(fd, "\\put(%03.2f,%03.2f){\\dashbox{0.5}(%03.2f,%03.2f)",
  1489.                  dashedBox_marker->x, newy(dashedBox_marker->v),
  1490.                 (dashedBox_marker->h - dashedBox_marker->x),
  1491.                 (dashedBox_marker->v - dashedBox_marker->y));
  1492.  
  1493.             fprintf(fd, "[");
  1494.  
  1495.             switch (dashedBox_marker->textpos[0])
  1496.             {
  1497.             case 'b':
  1498.                 fprintf(fd, "b");
  1499.                 break;
  1500.             case 't':
  1501.                 fprintf(fd, "t");
  1502.                 break;
  1503.             case 'l':
  1504.                 fprintf(fd, "l");
  1505.                 break;
  1506.             case 'r':
  1507.                 fprintf(fd, "r");
  1508.                 break;
  1509.             default:
  1510.                 fprintf(fd, "c");
  1511.                 break;
  1512.             }
  1513.  
  1514.             switch (dashedBox_marker->textpos[1])
  1515.             {
  1516.             case 'b':
  1517.                 fprintf(fd, "b");
  1518.                 break;
  1519.             case 't':
  1520.                 fprintf(fd, "t");
  1521.                 break;
  1522.             case 'l':
  1523.                 fprintf(fd, "l");
  1524.                 break;
  1525.             case 'r':
  1526.                 fprintf(fd, "r");
  1527.                 break;
  1528.             default:
  1529.                 fprintf(fd, "c");
  1530.                 break;
  1531.             }
  1532.  
  1533.             dashedBox_marker->text[strlen(dashedBox_marker->text)] = '\0';
  1534.  
  1535.             fprintf(fd, "]{%s}}\n", dashedBox_marker->text);
  1536.  
  1537.         } else
  1538.         {
  1539.             dashedBox_marker->x+=xmotion;
  1540.             dashedBox_marker->h+=xmotion;
  1541.             dashedBox_marker->y+=ymotion;
  1542.             dashedBox_marker->v+=ymotion;
  1543.             /* all moved now */
  1544.         }
  1545.  
  1546.         if (dashedBox_marker == dashedBox_curr)
  1547.             return;
  1548.  
  1549.         dashedBox_marker = dashedBox_marker->next;
  1550.  
  1551.     }
  1552. }
  1553.  
  1554.  
  1555.  
  1556. void
  1557. manage_kreis(int what, FILE * fd)
  1558. {/* medium must be open */
  1559.  
  1560.  
  1561.     kreis_marker = kreis_start;
  1562.  
  1563.     if (kreis_start == NULL)
  1564.         return;
  1565.  
  1566.     while (True)
  1567.     {
  1568.  
  1569.         if (what == 0)
  1570.         {
  1571.             dimension_update(kreis_marker->x - (float) kreis_marker->radius,
  1572.                 kreis_marker->y - (float) kreis_marker->radius);
  1573.             dimension_update(kreis_marker->x + (float) kreis_marker->radius,
  1574.                 kreis_marker->y + (float) kreis_marker->radius);
  1575.         } else if (what == 1)
  1576.         {
  1577.             fprintf(fd, "\\put(%03.2f,%03.2f){\\circle{%i}}\n",
  1578.                 kreis_marker->x, newy(kreis_marker->y),
  1579.                 kreis_marker->radius + kreis_marker->radius);
  1580.         } else
  1581.         {
  1582.             kreis_marker->x+=xmotion;
  1583.             kreis_marker->y+=ymotion;
  1584.         }
  1585.  
  1586.         if (kreis_marker == kreis_curr)
  1587.             return;
  1588.  
  1589.         kreis_marker = kreis_marker->next;
  1590.  
  1591.     }
  1592. }
  1593.  
  1594.  
  1595. void
  1596. manage_disc(int what, FILE * fd)
  1597. {/* medium must be open */
  1598.  
  1599.  
  1600.     disc_marker = disc_start;
  1601.  
  1602.     if (disc_start == NULL)
  1603.         return;
  1604.  
  1605.     while (True)
  1606.     {
  1607.  
  1608.         if (what == 0)
  1609.         {
  1610.             dimension_update(disc_marker->x - (float) disc_marker->radius,
  1611.                   disc_marker->y - (float) disc_marker->radius);
  1612.             dimension_update(disc_marker->x + (float) disc_marker->radius,
  1613.                   disc_marker->y + (float) disc_marker->radius);
  1614.         } else if (what == 1)
  1615.         {
  1616.             fprintf(fd, "\\put(%03.2f,%03.2f){\\circle*{%i}}\n",
  1617.                 disc_marker->x, newy(disc_marker->y),
  1618.                 disc_marker->radius + disc_marker->radius);
  1619.         } else
  1620.         {
  1621.             disc_marker->x+=xmotion;
  1622.             disc_marker->y+=ymotion;
  1623.         }
  1624.  
  1625.         if (disc_marker == disc_curr)
  1626.             return;
  1627.  
  1628.         disc_marker = disc_marker->next;
  1629.  
  1630.     }
  1631. }
  1632.  
  1633.  
  1634. void
  1635. manage_text(int what, FILE * fd)
  1636. {/* medium must be open */
  1637.  
  1638.  
  1639.     message_marker = message_start;
  1640.  
  1641.     if (message_start == NULL)
  1642.         return;
  1643.  
  1644.     while (True)
  1645.     {
  1646.  
  1647.         if (what == 0)
  1648.             dimension_update(message_marker->x, message_marker->y);
  1649.  
  1650.         else if (what == 1)
  1651.         {
  1652.             fprintf(fd, "\\put(%03.2f,%03.2f){\\makebox(0,0)[",
  1653.                 message_marker->x, newy(message_marker->y));
  1654.  
  1655.             switch (message_marker->textpos[0])
  1656.             {
  1657.             case 'b':    break;
  1658.             case 't':    break;
  1659.             case 'l':    break;
  1660.             case 'r':    break;
  1661.             default:    message_marker->textpos[0]='c';
  1662.                     break;
  1663.             }
  1664.  
  1665.             switch (message_marker->textpos[1])
  1666.             {
  1667.             case 'b':    break;
  1668.             case 't':    break;
  1669.             case 'l':    break;
  1670.             case 'r':    break;
  1671.             default:    message_marker->textpos[1]='c';
  1672.                     break;
  1673.             }
  1674.  
  1675.             fprintf(fd, "%c%c]{%s}}\n",
  1676.                 message_marker->textpos[0], message_marker->textpos[1],
  1677.                 message_marker->text);
  1678.         } else
  1679.         {
  1680.             message_marker->x+=xmotion;
  1681.             message_marker->y+=ymotion;
  1682.         }
  1683.  
  1684.             
  1685.  
  1686.         if (message_marker == message_curr)
  1687.             return;
  1688.  
  1689.         message_marker = message_marker->next;
  1690.  
  1691.     }
  1692. }
  1693.  
  1694.  
  1695.  
  1696.  
  1697. void
  1698. manage_oval(int what, FILE * fd)
  1699. {/* medium must be open */
  1700.  
  1701.  
  1702.     oval_marker = oval_start;
  1703.  
  1704.     if (oval_start == NULL)
  1705.         return;
  1706.  
  1707.     while (True)
  1708.     {
  1709.  
  1710.         /* normate rectangle */
  1711.         norm_rectangle(&oval_marker->x, &oval_marker->y,
  1712.                    &oval_marker->h, &oval_marker->v);
  1713.  
  1714.         if (what == 0)
  1715.         {
  1716.             dimension_update(oval_marker->x, oval_marker->y);
  1717.             dimension_update(oval_marker->h, oval_marker->v);
  1718.         } else if (what == 1)
  1719.         {
  1720.             fprintf(fd, "\\put(%03.2f,%03.2f){\\oval(%03.2f,%03.2f)}\n",
  1721.                 oval_marker->x + ((oval_marker->h - oval_marker->x) / 2),
  1722.                 newy(oval_marker->y + (oval_marker->v - oval_marker->y) / 2),
  1723.                 (oval_marker->h - oval_marker->x),
  1724.                 (oval_marker->v - oval_marker->y));
  1725.         } else
  1726.         {
  1727.             oval_marker->x+=xmotion;
  1728.             oval_marker->h+=xmotion;
  1729.             oval_marker->y+=ymotion;
  1730.             oval_marker->v+=ymotion;
  1731.         }
  1732.  
  1733.         if (oval_marker == oval_curr)
  1734.             return;
  1735.  
  1736.         oval_marker = oval_marker->next;
  1737.  
  1738.     }
  1739. }
  1740.